﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OpenUserAlerts.aspx.cs" Inherits="MLY.Reports.SCCoverReports.OpenUserAlerts" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Open alerts report</title>
    <style type="text/css">
        .TitleStyle
        {
            font-family:Arial Sans-Serif David;
            font-size:14px;
            font-weight:bold;
            color:Black;
        }
        .InerTextStyle
        {
            font-family:Arial Sans-Serif David;
            font-size:12px;
            color:Black;
        }
        
    </style>
    
</head>
<body>
    <form id="form1" runat="server">
    <div class="InerTextStyle">
        <asp:ToolkitScriptManager ID="ScriptManager1" runat="server"></asp:ToolkitScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <Triggers>
            <asp:PostBackTrigger ControlID="ExportImageButton" />
        </Triggers>
        <ContentTemplate>
        
        <asp:Label ID="PageTitleLabel" runat="server" CssClass="TitleStyle" Text="Open alerts report"></asp:Label>
        <br /><br />
        <table cellpadding="3" cellspacing="3">
        <tr>
        <td style="vertical-align:top;">
            <asp:Label ID="OrganizationsTitleLabel" runat="server" CssClass="InerTextStyle" Text="Choose organizations:"></asp:Label>
            <br />
            <asp:RadioButtonList ID="OrganizationsRadioButtonList" runat="server" AutoPostBack="true"
             CssClass="InerTextStyle" OnSelectedIndexChanged="ReloadOrgs" >
                <asp:ListItem Text="All" Value="0" Selected="True"></asp:ListItem>
            </asp:RadioButtonList>
            <asp:DropDownList ID="ddlContractors" runat="server" DataTextField="OrganizationName"
                DataValueField="OrganizationId" >
            </asp:DropDownList>
            <asp:DropDownList ID="ddlCustomers" runat="server" DataTextField="OrganizationName"
                DataValueField="OrganizationId" >
            </asp:DropDownList>
        </td>
        <td style="vertical-align:top;">
            <asp:RadioButtonList ID="DatesLimitRBL" runat="server" AutoPostBack="true"
             OnSelectedIndexChanged="DatesChanged" CssClass="InerTextStyle">
                <asp:ListItem Text="No dates limit" Value="0" Selected="True"></asp:ListItem>
                <asp:ListItem Text="Limit work order dates:" Value="1"></asp:ListItem>
            </asp:RadioButtonList>
            <asp:Panel ID="DatesPanel" runat="server" Visible="false" CssClass="InerTextStyle">
                <asp:DropDownList runat="server" ID="DateTypeDDL" CssClass="InerTextStyle">
                    <asp:ListItem Text="<%$Dict:clientAddWo.SendDate %>" Value="1" Selected="True"></asp:ListItem>
                    <asp:ListItem Text="<%$Dict:clientAddWo.RequestedDelivaryDate %>" Value="2"></asp:ListItem>
                    <asp:ListItem Text="<%$Dict:clientAddWo.PlannedDelivaryDate %>" Value="3"></asp:ListItem>                        
                    <asp:ListItem Text="<%$Dict:clientAddWo.ActualDelivaryDate %>" Value="4"></asp:ListItem>                                         
                </asp:DropDownList>
                <br /><br />
                <asp:Label ID="DateFromTitleLabel" runat="server" Text='<%$Dict:reportsParams.Between %>'></asp:Label>
                <br />
                <KBMControls:KBMReadOnlyTxtBox runat="server" ID="txtFromDate"></KBMControls:KBMReadOnlyTxtBox>
                <KBMValidators:requiredValidator ID="RequiredValidator1" runat="server" ControlToValidate="txtFromDate" ErrorMessage='<%$Dict:reportsParams.MustChooseBetweenTime %>'>
                </KBMValidators:requiredValidator>
                <KBMControls:KbmCalendar TargetControlID="txtFromDate" runat="server" ID="KbmCalendar1">
                </KBMControls:KbmCalendar>
                <br />
                <asp:Label ID="DateTillTitleLabel"  runat="server"  Text='<%$Dict:reportsParams.And %>'></asp:Label>
                <br />
                <KBMControls:KBMReadOnlyTxtBox runat="server" ID="txtToDate"></KBMControls:KBMReadOnlyTxtBox>
                <KBMValidators:requiredValidator ID="RequiredValidator2" ControlToValidate="txtToDate" ErrorMessage='<%$Dict:reportsParams.MustChooseToDate %>'
                    runat="server"></KBMValidators:requiredValidator>
                <KBMControls:KbmCalendar TargetControlID="txtToDate" runat="server" ID="Calendar1">
                </KBMControls:KbmCalendar>
            </asp:Panel>
        </td>
        <td style="vertical-align:top;">
            <asp:RadioButtonList ID="AlertIdRBL" runat="server" AutoPostBack="true" OnSelectedIndexChanged="alertRBLChange">
                <asp:ListItem Text="All alerts" Selected="True" Value="0"></asp:ListItem>
                <asp:ListItem Text="Only:" Value="1"></asp:ListItem>
            </asp:RadioButtonList>
            <asp:DropDownList ID="UserAlertsDDL" runat="server" DataTextField="AlertName"
             DataValueField="AlertId" DataSourceID="UserAlertsDataSource" Visible="false"></asp:DropDownList>
         
        </td>
        <td style="vertical-align:top;">
            <asp:RadioButtonList ID="OpenClosedRDL" runat="server" CssClass="InerTextStyle" >
                <asp:ListItem Selected="True" Text="Open alerts" Value="1"></asp:ListItem>
                <asp:ListItem Selected="False" Text="Closed alerts" Value="0"></asp:ListItem>
            </asp:RadioButtonList>
        </td>
        </tr>
        </table>
        <br /><br />         
        <asp:Button ID="GenerateReportButton" runat="server" Text="Generate report" OnClick="ReloadReport" />
        <div style="height:20px;">
            <asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel1" runat="server">
                <ProgressTemplate>
                    <div class="InerTextStyle">Loading...</div>
                </ProgressTemplate>
            </asp:UpdateProgress>
        </div>
        <br /><hr /><br />
        <asp:Button ID="CloseSelectedButton" runat="server" Text="Close selected alerts" OnClick="CloseSelected" />
        &nbsp;&nbsp;
        <asp:ImageButton ID="ExportImageButton" runat="server" ImageUrl="~/Images/excel.gif"
                 OnClick="ExportToExcel" ToolTip="Export to csv file" />
        <br />         
        <asp:GridView ID="ReportGridview" runat="server" AutoGenerateColumns="false" AllowPaging="false"
         DataSourceID="ReportDataSource" >
             <HeaderStyle BackColor="#86C2FF" />
             <RowStyle CssClass="InerTextStyle" />
             <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HiddenField ID="MarkingIdHiddenField" runat="server" Value='<%# Eval("MarkingId") %>' />
                        <asp:CheckBox ID="CloseCheckBox" runat="server" ToolTip="Close" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="AlertName" HeaderText="AlertName" />
                <asp:BoundField DataField="ContractorOrganizationName" HeaderText="Contractor"  />
                <asp:BoundField DataField="CustomerOrganizationName" HeaderText="Customer" />
                <asp:BoundField DataField="CustomerWorkOrderNumber" HeaderText="Customer work order number" />
                <asp:BoundField DataField="ContractorWorkOrderNumber" HeaderText="Contractor work order number" />
                <asp:BoundField DataField="ContractorLotNumber" HeaderText="Supplier lot number" />
                <asp:BoundField DataField="SendDate" HeaderText="Send Date" />
                <asp:BoundField DataField="RequestedDelivaryDate" HeaderText="Requested delivery date" />
                <asp:BoundField DataField="PlannedDelivaryDate" HeaderText="Planned delivery date" />
                <asp:BoundField DataField="CustomerPriority" HeaderText="Priority" />
                <asp:BoundField DataField="Quantity" HeaderText="Quantity" />
                <asp:BoundField DataField="originalQuantity" HeaderText="Original quantity" />
                <asp:BoundField DataField="CustomerCatalougeCode" HeaderText="Customer Catalouge Code" />
                <asp:BoundField DataField="ContractorCatalogueCode" HeaderText="Contractor catalogue code" />
                <asp:BoundField DataField="ProductDescription" HeaderText="Product description" />
                <asp:BoundField DataField="Remarks" HeaderText="Remarks" />
                <asp:BoundField DataField="OrderNumber" HeaderText="Order number" />
                <asp:BoundField DataField="SplitId" HeaderText="Split Id" />
            </Columns>
            <EmptyDataTemplate>
               <div class="InerTextStyle">No items matching the request detected</div>
            </EmptyDataTemplate>
            </asp:GridView>
            
        <br />
        <asp:Button ID="CloseSelectedButton2" runat="server" Text="Close selected alerts" OnClick="CloseSelected" />
        <asp:SqlDataSource ID="ReportDataSource" runat="server" SelectCommandType="StoredProcedure"
            ConnectionString="<%$ ConnectionStrings:MLYConnectionString %>" 
            SelectCommand="SCCover_Reports_ShowOpenAlerts"></asp:SqlDataSource> 
        <asp:SqlDataSource ID="UserAlertsDataSource" runat="server" SelectCommandType="StoredProcedure"
            ConnectionString="<%$ ConnectionStrings:MLYConnectionString %>" 
            SelectCommand="AlertGetUserAlerts"></asp:SqlDataSource> 
        </ContentTemplate>
        </asp:UpdatePanel>        
    </div>
    </form>
</body>
</html>
